package com.example.mybatisx.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mybatisx.entity.SysUser;
import com.example.mybatisx.mapper.SysUserMapper;
import com.example.mybatisx.service.SysUserService;
import com.example.mybatisx.service.SysUserSlaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* @author Geoffrey
* @description 针对表【sys_user】的数据库操作Service实现
* @createDate 2023-04-18 17:25:27
*/
@Service
@DS("master")
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
    implements SysUserService{

    @Autowired
    private SysUserMapper sysUserMapper;

    @Autowired
    private SysUserSlaveService sysUserSlaveService;

    @Override
    public Object getMasterUser(){
        return lambdaQuery().list();
    }

    @Override
    @Transactional
    public Object addMasterUser() {
        SysUser sysUser =new SysUser("zzzzzz",5);
        sysUserMapper.insert(sysUser);
        sysUserSlaveService.addSlaveUser();
        return "success";
    }

}




